home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 72 / IOPROG_72.ISO / soft / c++ / NCTDiscWriter2.exe / {app} / MS C# 7.0 Samples / TestCSAudioCDRipper / Form1.cs < prev    next >
Encoding:
Text File  |  2003-04-02  |  18.1 KB  |  555 lines

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7.  
  8. namespace TestCSharpAudioCDRipper
  9. {
  10.     public struct RipList
  11.     {
  12.         public string FileName;
  13.         public int TracNum;
  14.  
  15.         public RipList(int index)
  16.         {
  17.             TracNum = 0;
  18.             FileName = "";
  19.         }
  20.     }
  21.  
  22.     /// <summary>
  23.     /// Summary description for Form1.
  24.     /// </summary>
  25.     public class Form1 : System.Windows.Forms.Form
  26.     {
  27.         internal System.Windows.Forms.ListView lvTracks;
  28.         internal System.Windows.Forms.ColumnHeader ColumnHeader1;
  29.         internal System.Windows.Forms.ColumnHeader ColumnHeader2;
  30.         internal System.Windows.Forms.Panel Panel1;
  31.         internal System.Windows.Forms.TextBox txtAlbum;
  32.         internal System.Windows.Forms.TextBox txtArtist;
  33.         internal System.Windows.Forms.ComboBox cbDrive;
  34.         internal System.Windows.Forms.ToolBar ToolBar1;
  35.         internal System.Windows.Forms.ToolBarButton ToolBarButton10;
  36.         internal System.Windows.Forms.ToolBarButton btnEject;
  37.         internal System.Windows.Forms.ToolBarButton btnRefreshCD;
  38.         internal System.Windows.Forms.ToolBarButton btnGetCDDB;
  39.         internal System.Windows.Forms.ToolBarButton btnRipNow;
  40.         internal System.Windows.Forms.ImageList ImageList1;
  41.         private System.Windows.Forms.StatusBar statusBar1;
  42.         private System.Windows.Forms.StatusBarPanel statusBarPanel4;
  43.         private System.Windows.Forms.StatusBarPanel statusBarPanel1;
  44.         private System.Windows.Forms.StatusBarPanel statusBarPanel2;
  45.         private System.Windows.Forms.StatusBarPanel statusBarPanel3;
  46.         private System.ComponentModel.IContainer components;
  47.  
  48.         public Form1()
  49.         {
  50.             //
  51.             // Required for Windows Form Designer support
  52.             //
  53.             InitializeComponent();
  54.  
  55.             //
  56.             // TODO: Add any constructor code after InitializeComponent call
  57.             //
  58.         }
  59.         Form2 frmProgress;
  60.  
  61.         /// <summary>
  62.         /// Clean up any resources being used.
  63.         /// </summary>
  64.         protected override void Dispose( bool disposing )
  65.         {
  66.             if( disposing )
  67.             {
  68.                 if (components != null) 
  69.                 {
  70.                     components.Dispose();
  71.                 }
  72.             }
  73.             base.Dispose( disposing );
  74.         }
  75.  
  76.         #region Windows Form Designer generated code
  77.         /// <summary>
  78.         /// Required method for Designer support - do not modify
  79.         /// the contents of this method with the code editor.
  80.         /// </summary>
  81.         private void InitializeComponent()
  82.         {
  83.             this.components = new System.ComponentModel.Container();
  84.             System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
  85.             this.lvTracks = new System.Windows.Forms.ListView();
  86.             this.ColumnHeader1 = new System.Windows.Forms.ColumnHeader();
  87.             this.ColumnHeader2 = new System.Windows.Forms.ColumnHeader();
  88.             this.Panel1 = new System.Windows.Forms.Panel();
  89.             this.txtAlbum = new System.Windows.Forms.TextBox();
  90.             this.txtArtist = new System.Windows.Forms.TextBox();
  91.             this.cbDrive = new System.Windows.Forms.ComboBox();
  92.             this.ToolBar1 = new System.Windows.Forms.ToolBar();
  93.             this.ToolBarButton10 = new System.Windows.Forms.ToolBarButton();
  94.             this.btnEject = new System.Windows.Forms.ToolBarButton();
  95.             this.btnRefreshCD = new System.Windows.Forms.ToolBarButton();
  96.             this.btnGetCDDB = new System.Windows.Forms.ToolBarButton();
  97.             this.btnRipNow = new System.Windows.Forms.ToolBarButton();
  98.             this.ImageList1 = new System.Windows.Forms.ImageList(this.components);
  99.             this.statusBar1 = new System.Windows.Forms.StatusBar();
  100.             this.statusBarPanel4 = new System.Windows.Forms.StatusBarPanel();
  101.             this.statusBarPanel1 = new System.Windows.Forms.StatusBarPanel();
  102.             this.statusBarPanel2 = new System.Windows.Forms.StatusBarPanel();
  103.             this.statusBarPanel3 = new System.Windows.Forms.StatusBarPanel();
  104.             this.Panel1.SuspendLayout();
  105.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).BeginInit();
  106.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).BeginInit();
  107.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).BeginInit();
  108.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).BeginInit();
  109.             this.SuspendLayout();
  110.             // 
  111.             // lvTracks
  112.             // 
  113.             this.lvTracks.CheckBoxes = true;
  114.             this.lvTracks.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
  115.                                                                                        this.ColumnHeader1,
  116.                                                                                        this.ColumnHeader2});
  117.             this.lvTracks.Dock = System.Windows.Forms.DockStyle.Fill;
  118.             this.lvTracks.FullRowSelect = true;
  119.             this.lvTracks.GridLines = true;
  120.             this.lvTracks.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
  121.             this.lvTracks.HideSelection = false;
  122.             this.lvTracks.Location = new System.Drawing.Point(0, 97);
  123.             this.lvTracks.Name = "lvTracks";
  124.             this.lvTracks.Size = new System.Drawing.Size(534, 277);
  125.             this.lvTracks.TabIndex = 6;
  126.             this.lvTracks.View = System.Windows.Forms.View.Details;
  127.             // 
  128.             // ColumnHeader1
  129.             // 
  130.             this.ColumnHeader1.Text = "Track";
  131.             this.ColumnHeader1.Width = 400;
  132.             // 
  133.             // ColumnHeader2
  134.             // 
  135.             this.ColumnHeader2.Text = "Duration";
  136.             // 
  137.             // Panel1
  138.             // 
  139.             this.Panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
  140.                                                                                  this.txtAlbum,
  141.                                                                                  this.txtArtist,
  142.                                                                                  this.cbDrive});
  143.             this.Panel1.Dock = System.Windows.Forms.DockStyle.Top;
  144.             this.Panel1.Location = new System.Drawing.Point(0, 55);
  145.             this.Panel1.Name = "Panel1";
  146.             this.Panel1.Size = new System.Drawing.Size(534, 42);
  147.             this.Panel1.TabIndex = 5;
  148.             // 
  149.             // txtAlbum
  150.             // 
  151.             this.txtAlbum.Dock = System.Windows.Forms.DockStyle.Fill;
  152.             this.txtAlbum.Location = new System.Drawing.Point(0, 21);
  153.             this.txtAlbum.Name = "txtAlbum";
  154.             this.txtAlbum.Size = new System.Drawing.Size(238, 20);
  155.             this.txtAlbum.TabIndex = 1;
  156.             this.txtAlbum.Text = "";
  157.             // 
  158.             // txtArtist
  159.             // 
  160.             this.txtArtist.Dock = System.Windows.Forms.DockStyle.Right;
  161.             this.txtArtist.Location = new System.Drawing.Point(238, 21);
  162.             this.txtArtist.Name = "txtArtist";
  163.             this.txtArtist.Size = new System.Drawing.Size(296, 20);
  164.             this.txtArtist.TabIndex = 2;
  165.             this.txtArtist.Text = "";
  166.             // 
  167.             // cbDrive
  168.             // 
  169.             this.cbDrive.Dock = System.Windows.Forms.DockStyle.Top;
  170.             this.cbDrive.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  171.             this.cbDrive.Name = "cbDrive";
  172.             this.cbDrive.Size = new System.Drawing.Size(534, 21);
  173.             this.cbDrive.TabIndex = 0;
  174.             // 
  175.             // ToolBar1
  176.             // 
  177.             this.ToolBar1.Appearance = System.Windows.Forms.ToolBarAppearance.Flat;
  178.             this.ToolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
  179.                                                                                         this.ToolBarButton10,
  180.                                                                                         this.btnEject,
  181.                                                                                         this.btnRefreshCD,
  182.                                                                                         this.btnGetCDDB,
  183.                                                                                         this.btnRipNow});
  184.             this.ToolBar1.DropDownArrows = true;
  185.             this.ToolBar1.ImageList = this.ImageList1;
  186.             this.ToolBar1.Name = "ToolBar1";
  187.             this.ToolBar1.ShowToolTips = true;
  188.             this.ToolBar1.Size = new System.Drawing.Size(534, 55);
  189.             this.ToolBar1.TabIndex = 4;
  190.             this.ToolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.ToolBar1_ButtonClick_1);
  191.             // 
  192.             // ToolBarButton10
  193.             // 
  194.             this.ToolBarButton10.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
  195.             // 
  196.             // btnEject
  197.             // 
  198.             this.btnEject.ImageIndex = 0;
  199.             this.btnEject.Tag = "0";
  200.             this.btnEject.Text = "Eject";
  201.             // 
  202.             // btnRefreshCD
  203.             // 
  204.             this.btnRefreshCD.ImageIndex = 1;
  205.             this.btnRefreshCD.Tag = "1";
  206.             this.btnRefreshCD.Text = "Refresh CD";
  207.             // 
  208.             // btnGetCDDB
  209.             // 
  210.             this.btnGetCDDB.ImageIndex = 2;
  211.             this.btnGetCDDB.Tag = "2";
  212.             this.btnGetCDDB.Text = "Get CDDB";
  213.             // 
  214.             // btnRipNow
  215.             // 
  216.             this.btnRipNow.ImageIndex = 3;
  217.             this.btnRipNow.Tag = "3";
  218.             this.btnRipNow.Text = "Rip Now";
  219.             // 
  220.             // ImageList1
  221.             // 
  222.             this.ImageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth24Bit;
  223.             this.ImageList1.ImageSize = new System.Drawing.Size(32, 32);
  224.             this.ImageList1.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("ImageList1.ImageStream")));
  225.             this.ImageList1.TransparentColor = System.Drawing.Color.Transparent;
  226.             // 
  227.             // statusBar1
  228.             // 
  229.             this.statusBar1.Location = new System.Drawing.Point(0, 352);
  230.             this.statusBar1.Name = "statusBar1";
  231.             this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
  232.                                                                                           this.statusBarPanel4,
  233.                                                                                           this.statusBarPanel1,
  234.                                                                                           this.statusBarPanel2,
  235.                                                                                           this.statusBarPanel3});
  236.             this.statusBar1.ShowPanels = true;
  237.             this.statusBar1.Size = new System.Drawing.Size(534, 22);
  238.             this.statusBar1.TabIndex = 7;
  239.             this.statusBar1.Text = "statusBar1";
  240.             // 
  241.             // statusBarPanel4
  242.             // 
  243.             this.statusBarPanel4.Width = 50;
  244.             // 
  245.             // statusBarPanel1
  246.             // 
  247.             this.statusBarPanel1.Width = 150;
  248.             // 
  249.             // statusBarPanel2
  250.             // 
  251.             this.statusBarPanel2.Width = 150;
  252.             // 
  253.             // statusBarPanel3
  254.             // 
  255.             this.statusBarPanel3.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
  256.             this.statusBarPanel3.Width = 168;
  257.             // 
  258.             // Form1
  259.             // 
  260.             this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  261.             this.ClientSize = new System.Drawing.Size(534, 374);
  262.             this.Controls.AddRange(new System.Windows.Forms.Control[] {
  263.                                                                           this.statusBar1,
  264.                                                                           this.lvTracks,
  265.                                                                           this.Panel1,
  266.                                                                           this.ToolBar1});
  267.             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
  268.             this.Name = "Form1";
  269.             this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
  270.             this.Text = "TestCSharpAudioCDRipper";
  271.             this.Load += new System.EventHandler(this.Form1_Load);
  272.             this.Panel1.ResumeLayout(false);
  273.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel4)).EndInit();
  274.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
  275.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel2)).EndInit();
  276.             ((System.ComponentModel.ISupportInitialize)(this.statusBarPanel3)).EndInit();
  277.             this.ResumeLayout(false);
  278.  
  279.         }
  280.         #endregion
  281.  
  282.         /// <summary>
  283.         /// The main entry point for the application.
  284.         /// </summary>
  285.         [STAThread]
  286.         static void Main() 
  287.         {
  288.             Application.Run(new Form1());
  289.         }
  290.  
  291.         NCTDISCRIPPERLib.AudioCDRipperClass ripper;
  292.         public bool CancelRip;
  293.         public long RipCount, RipCurrent, cddbSource, mripModePreset, m_Format;
  294.  
  295.         private void Form1_Load(object sender, System.EventArgs e)
  296.         {
  297.             ripper = new NCTDISCRIPPERLib.AudioCDRipperClass();
  298.  
  299.             ripper.RipProgress += new NCTDISCRIPPERLib._IAudioCDRipperEvents_RipProgressEventHandler(this.AudioCDRipper1_RipProgress);
  300.             ripper.CDDBQueryStatus += new NCTDISCRIPPERLib._IAudioCDRipperEvents_CDDBQueryStatusEventHandler(this.AudioCDRipper1_CDDBQueryStatus);
  301.             ripper.MediaChange += new NCTDISCRIPPERLib._IAudioCDRipperEvents_MediaChangeEventHandler(this.AudioCDRipper1_MediaChange);
  302.             ripper.RipRetry += new NCTDISCRIPPERLib._IAudioCDRipperEvents_RipRetryEventHandler(this.AudioCDRipper1_RipRetry);
  303.  
  304.             ripper.DriverOpen();
  305.  
  306.             cddbSource = 0;
  307.             mripModePreset = 1;
  308.             m_Format = 0;
  309.             
  310.             frmProgress = new Form2();
  311.             frmProgress.form = this;
  312.             
  313.             RefreshCD();    
  314.         }
  315.         private void RefreshCD()
  316.         {
  317.             statusBar1.Panels[0].Text = "RefreshCD";
  318.             PLEnable(false);
  319.             TBBtnEnable(false);
  320.             ripper.Refresh();                //Re-read CD drive
  321.             cbDrive.Items.Clear();
  322.             for (int i = 1; i <= ripper.driveCount; i++)
  323.             {
  324.                 ripper.driveNum = i;
  325.                 cbDrive.Items.Add("(" + ripper.driveLetter + ")  " + ripper.driveName);
  326.             }
  327.             if (cbDrive.Items.Count > 0) 
  328.             {
  329.                 cbDrive.SelectedIndex = 0;
  330.                 cbDrive_SelectedIndexChanged(null, null);
  331.             }
  332.  
  333.             ReloadInfo();
  334.             statusBar1.Panels[0].Text = "Ready";
  335.  
  336.             switch (ripper.cdType)
  337.             {
  338.                 case NCTDISCRIPPERLib.CDDiskTypeConstants.REDBOOK : statusBar1.Panels[1].Text = "CD-DA (Audio Disk)"; break;
  339.                 case NCTDISCRIPPERLib.CDDiskTypeConstants.YELLOWBOOK : statusBar1.Panels[1].Text = "Data CD"; break;
  340.                 case NCTDISCRIPPERLib.CDDiskTypeConstants.ORANGEBOOK : statusBar1.Panels[1].Text = "Data CD"; break;
  341.                 case NCTDISCRIPPERLib.CDDiskTypeConstants.GREENBOOK : statusBar1.Panels[1].Text = "CD-Interactive"; break;
  342.                 case NCTDISCRIPPERLib.CDDiskTypeConstants.BLUEBOOK : statusBar1.Panels[1].Text = "CD-Extra"; break;
  343.                 case NCTDISCRIPPERLib.CDDiskTypeConstants.UNRECOGNIZED : statusBar1.Panels[1].Text = "No Disk"; break;
  344.             }
  345.  
  346.             statusBar1.Panels[2].Text = "CDDB Disk ID: " + ripper.cdID.ToString("X");
  347.         }
  348.  
  349.         private string MyIntToString(int Number)
  350.         {
  351.             if (Number > 9) return Number.ToString();
  352.             return "0" + Number.ToString();
  353.         }
  354.  
  355.         private void ReloadInfo()
  356.         {
  357.             PLEnable(false);
  358.             TBBtnEnable(false);
  359.             ripper.GetCDDBInfo(NCTDISCRIPPERLib.CDDBSourceConstants.CDPLAYERINI);
  360.             statusBar1.Panels[3].Text = "CDDB Status: IDLE";
  361.             txtAlbum.Text = ripper.cddbInfoAlbum;
  362.             txtArtist.Text = ripper.cddbInfoArtist;
  363.  
  364.             if (txtArtist.Text.Length < 1) txtArtist.Text = "Unknown Artist";
  365.             if (txtAlbum.Text.Length < 1) txtAlbum.Text = "Unknown Album";
  366.  
  367.             lvTracks.BeginUpdate();
  368.             lvTracks.Items.Clear();
  369.  
  370.             if (ripper.trackCount != 0)
  371.             {
  372.                 for (int i = 1; i <= ripper.trackCount; i++)
  373.                 {
  374.                     ripper.trackNum = i;
  375.                     ListViewItem li;
  376.                     if (ripper.cddbInfoTitle.Length > 0)
  377.                         li = lvTracks.Items.Add(MyIntToString(i) + " " + ripper.cddbInfoTitle);
  378.                     else
  379.                         li = lvTracks.Items.Add("Track " + MyIntToString(i));
  380.  
  381.                     li.Checked = true;
  382.                     int min = ripper.trackDuration / 60000;
  383.                     int sec = ripper.trackDuration / 1000 - min * 60;
  384.                     li.SubItems.Add(MyIntToString(min) + ":" + MyIntToString(sec));
  385.                 }
  386.                 ripper.trackNum = 1;
  387.                 lvTracks.Items[0].Focused = true;
  388.                 PLEnable(true);
  389.                 TBBtnEnable(true);
  390.             }
  391.             else
  392.             {
  393.                 TBBtnEnable(true);
  394.                 btnGetCDDB.Enabled = false;
  395.                 btnRipNow.Enabled = false;
  396.                 PLEnable(false);
  397.             }
  398.  
  399.             lvTracks.EndUpdate();
  400.         }
  401.  
  402.     
  403.         private void Form1_Closing(object sender, System.ComponentModel.CancelEventArgs e)
  404.         {
  405.             ripper.DriverClose();
  406.             frmProgress.Dispose();
  407.         }
  408.  
  409.         private void PLEnable(bool Enable)
  410.         {
  411.             lvTracks.Enabled = Enable;
  412.         }
  413.  
  414.         private void TBBtnEnable(bool Enable)
  415.         {
  416.             btnEject.Enabled = Enable;
  417.             btnRefreshCD.Enabled = Enable;
  418.             btnGetCDDB.Enabled = Enable;
  419.             btnRipNow.Enabled = Enable;
  420.         }
  421.  
  422.         private void RipNow()
  423.         {
  424.             PLEnable(false);
  425.             TBBtnEnable(false);
  426.             ArrayList Rip = new ArrayList();
  427.             RipList gl;
  428.  
  429.             RipCount = 0;
  430.             for (int i = 0; i < lvTracks.Items.Count; i++)
  431.             {
  432.                 if (lvTracks.Items[i].Checked)
  433.                 {
  434.                     gl = new RipList();
  435.                     gl.TracNum = i + 1;
  436.                     gl.FileName = lvTracks.Items[i].Text;
  437.                     RipCount += 1;
  438.                     Rip.Add(gl);
  439.                 }
  440.             }
  441.             if (RipCount < 1)
  442.             {
  443.                 MessageBox.Show("No files to rip.");
  444.                 PLEnable(true);
  445.                 TBBtnEnable(true);
  446.                 return;
  447.             }
  448.             Refresh();
  449.             frmProgress.pb1.Value = 0;
  450.             frmProgress.pb2.Value = 0;
  451.             frmProgress.Show();
  452.             frmProgress.Refresh();
  453.             CancelRip = false;
  454.             ripper.ripModePreset = (NCTDISCRIPPERLib.RipModePresetConstants)mripModePreset;
  455.             for (int i = 1; i <= Rip.Count; i++)
  456.             {
  457.                 if (CancelRip) break;
  458.                 RipCurrent = i;
  459.                 gl = (RipList)Rip[i-1];
  460.                 ripper.trackNum = gl.TracNum;
  461.                 frmProgress.FileName = gl.FileName + ".mp3";
  462.                 Application.DoEvents();   //Yields execution so that operating system could produce the other events
  463.                 ripper.SetFormatMP3(NCTDISCRIPPERLib.RipFrequencyConstants.FQ_44_KHZ, NCTDISCRIPPERLib.RipBitrateConstants.BR_128_KBPS, NCTDISCRIPPERLib.RipChannelsConstants.STEREO);
  464.                 frmProgress.pb1.Value = 0;
  465.                 ripper.RipTrackToMP3(gl.FileName);
  466.                 while(frmProgress.pb1.Value != 100)
  467.                     Application.DoEvents();
  468.             }
  469.             for (int i = 1; i<= Rip.Count; i++) Rip.Remove(i);
  470.             frmProgress.Hide();
  471.             PLEnable(true);
  472.             TBBtnEnable(true);
  473.         }
  474.  
  475.  
  476.         private void AudioCDRipper1_CDDBQueryStatus(NCTDISCRIPPERLib.CDDBQueryStatusConstants status)
  477.         {
  478.             switch (status)
  479.             {
  480.                 case NCTDISCRIPPERLib.CDDBQueryStatusConstants.QUERY : 
  481.                     statusBar1.Panels[3].Text = "CDDB Status: QUERY";
  482.                     break;
  483.                 case NCTDISCRIPPERLib.CDDBQueryStatusConstants.PROCESSANSWER : 
  484.                     statusBar1.Panels[3].Text = "CDDB Status: PROCESS ANSWER";
  485.                     break;
  486.             }
  487.         }
  488.  
  489.         private void AudioCDRipper1_RipRetry(int retryNum)
  490.         {
  491.             frmProgress.DrawTextMy("Read or Synch Error! Retry.");
  492.             Application.DoEvents();   //Yields execution so that operating system could produce the other events
  493.             if (CancelRip) ripper.StopRip();
  494.         }
  495.  
  496.         private void AudioCDRipper1_RipProgress(int percent)
  497.         {
  498.             Application.DoEvents();   //Yields execution so that operating system could produce the other events
  499.             frmProgress.DrawTextMy("");
  500.             frmProgress.pb1.Value = percent;
  501.             frmProgress.pb2.Value = (int)(((RipCurrent-1) * 100 + percent) / RipCount);
  502.             Application.DoEvents();
  503.             if (CancelRip) ripper.StopRip();
  504.         }
  505.  
  506.         private void AudioCDRipper1_MediaChange()
  507.         {
  508.             RefreshCD();
  509.         }
  510.  
  511.         private void cbDrive_SelectedIndexChanged(object sender, System.EventArgs e)
  512.         {
  513.             ripper.driveNum = cbDrive.SelectedIndex + 1;
  514.         }
  515.  
  516.         private void ToolBar1_ButtonClick_1(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
  517.         {
  518.             switch (e.Button.Tag.ToString())
  519.             {
  520.                 case "0": 
  521.                     ripper.Eject();
  522.                     break;
  523.                 case "1": 
  524.                     RefreshCD();
  525.                     break;
  526.                 case "2":
  527.                     bool CDDBInfoEnabled = false;
  528.                 switch(cddbSource)
  529.                 {
  530.                     case 1 : CDDBInfoEnabled = ripper.GetCDDBInfo(NCTDISCRIPPERLib.CDDBSourceConstants.ONLINEDATABASE); break;
  531.                     case 2 : CDDBInfoEnabled = ripper.GetCDDBInfo(NCTDISCRIPPERLib.CDDBSourceConstants.CDPLAYERINI); break;
  532.                     case 3 : CDDBInfoEnabled = ripper.GetCDDBInfo(NCTDISCRIPPERLib.CDDBSourceConstants.ALL); break;
  533.                 }
  534.  
  535.                     if (CDDBInfoEnabled)
  536.                     {
  537.                         txtAlbum.Text = ripper.cddbInfoAlbum;
  538.                         txtArtist.Text = ripper.cddbInfoArtist;
  539.                         ReloadInfo();
  540.                     }
  541.                     else
  542.                         MessageBox.Show("No CDDB Information available! Try other CDDB source.");
  543.                     
  544.                     statusBar1.Panels[3].Text = "CDDB Status: IDLE";
  545.                     break;
  546.                 case "3": 
  547.                     RipNow();
  548.                     break;
  549.             }
  550.         }
  551.  
  552.  
  553.     }
  554. }
  555.